# @Time : 2021/2/11 17:49
# @Author : Li Kunlun
# @Description :
import numpy as np

a = np.arange(4)
# [0 1 2 3]
print(a)
b = np.arange(4)[::-1]
# [3 2 1 0]
print(b)

c = X_BOUND = [0, 5]
print(c)
# <class 'list'>
print(type(c))
print(c[1])

print("-----------初始化DNA------------")
POP_SIZE = 100
DNA_SIZE = 10
X_BOUND = [0, 5]
# 产生尺寸为100*10的（0，1）矩阵
# [[0 1 0 0 1 0 0 1 0 0]
# [0 1 1 1 0 0 1 1 1 0]
#  [0, low-->2)区间的整数
pop = np.random.randint(2, size=(100, DNA_SIZE))
print("-----------------------")


def translateDNA(pop):
    return pop.dot(2 ** np.arange(DNA_SIZE)[::-1]) / float(2 ** DNA_SIZE - 1) * X_BOUND[1]


# print(translateDNA())

print("----------_测试-------------")
test01 = [3, 8]
for _ in range(len(test01)):
    print(test01)

print("-----------------------")
Flag = np.array([1, 0, 0, 1]).astype(np.bool)
# # [ True False False  True]
print(Flag)
t1 = np.array([1, 2, 3, 4])
t2 = np.array([5, 6, 7, 8])
print(np.array([1, 2, 3, 4]))
# [1 4]
print(t1[Flag])
t2[Flag] = t1[Flag]
# [1 6 7 4]
print(t2)
